<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    let fun = (num) => {
      for (let i = num + 1; ; i++) {
        let flag = true
        if (i < 2) continue
        for (let j = 2; j < i; j++) {
          if (i % j == 0) {
            flag = false
            break
          }
        }
        if (flag) return i
      }

    }
    var primeSubOperation = function (nums) {
      for (let i = nums.length - 2; i >= 0; i--) {
        let num = nums[i] - nums[i + 1]
        if (num < 0) continue
        nums[i] -= fun(num)
        if (nums[i] < 1) return false
      }
      console.log(nums);
      return true
    }
    console.log(fun([4, 9, 6, 10]))
    // primeSubOperation([4, 9, 6, 10])
  </script>
</body>

</html>